/**
 * 制作者：九哥
 * 我的数据对接
 * 时间：2019-03-01
 * 更新者：
 * */





/**
 * 引入缓存设置文件 cache.js
 * */
document.write("<script type='text/javascript' src='/h5/js/cache.js'></script>");





//var app_access = 'qSoiKwpWVge4TkaryH6MKvOdceGt7ZMaF20g8H0cnXI';





///**
// * 判断是否登录
// * */
//function getUserInfo(){
//    var userInfo = cacheGet('userInfo'); //获取用户信息
//    if (userInfo==null || userInfo.token=='undefined') {
//        //getErrMsg('没有登录！',''); return;
//        window.location.href = '/h5/login/login.html';
//    }
//}

/**
 * --------------------
 * 我的主页面
 * --------------------
 * */

/**
 * 获取用户昵称、头像等
 * */
function getUserInfo(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
   /*
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/userinfo',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            var h = '';
            if (res.data.head!='') {
                h += '<img src="'+res.data.head+'">';
            } else {
                h += '<img src="images/user-default.png">';
            }
            h += '<div class="loginTitle">';
            h += res.data.nickname;
            h += '<div style="font-size:14px;">';
            h += res.data.typeName;
            h += '</div>';
            h += '</div>';
            $('#mysetTitle').html(h);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    }); 
    
    */
    
}

/**
 * --------------------
 * 我的主页面
 * --------------------
 * */





/**
 * --------------------
 * 我的信息
 * --------------------
 * */

/**
 * 获取用户昵称、头像、性别
 * */
function getSettingUserInfo(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/userinfo',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            var h = '', h2 = '', sex = res.data.sex;
            if (res.data.head!='') {
                h += '<img src="'+res.data.head+'">';
            } else {
                h += '<img src="../../images/user-default.png">';
            }
            $('#head').html(h);
            $('#nickname').html(res.data.nickname);
            if (sex==1) {
                h2 += '男';
            } else if (sex==2) {
                h2 += '女';
            } else {
                h2 += '未定义';
            }
            $('#sexName').html(h2);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 头像编辑
 * */
function getHead(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var h = '';
    h += '<style>form { text-align:center; } form input[type="file"] { width:80%; } form p { margin-top:10px; } form p input { margin:0 5px;padding:5px 10px;background:#0088cc;color:#ffffff; } #submit { display:none; }</style>';
    h += '<form action="'+MC.HOST+'/api/my/myset/head-upload" method="post" enctype="multipart/form-data">';
    h += '<input type="hidden" name="app_access" value="'+app_access+'"/>';
    h += '<input type="hidden" name="token" value="'+userInfo.token+'"/>';
    h += '<input type="hidden" name="type" value="'+userInfo.type+'"/>';
    h += '<input type="hidden" name="cate" value="'+userInfo.cate+'"/>';
    h += '<input type="hidden" name="viewJump" value="/h5/my/setting/info.html"/>';
    h += '<input type="file" name="file" onchange="$(\'#submit\').show()">';
    h += '<p><input type="submit" value="立即更新" id="submit"> <input type="button" value="随时取消" onclick="popClose()"></p>';
    h += '</form>';
    $('#popDetail').html(h);
    $('#pop').show();
}

/**
 * 昵称编辑
 * */
function getNickname(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var h = '';
    h += '<style>input[type="text"] { margin:10px;border-bottom:1px solid #0088cc;; } p {  text-align:center; } p input { margin:0 5px;padding:10px 20px;background:#0088cc;border-radius:5px;color:#ffffff; }</style>';
    h += '<input type="text" id="nick" placeholder="昵称更新" value=""/>';
    h += '<p><input type="button" value="立即更新" onclick="setNickname()"> <input type="button" value="随时取消" onclick="popClose()"></p>';
    $('#popDetail').html(h);
    $('#pop').show();
}

/**
 * 昵称更新
 * */
function setNickname(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var nickname = $('#nick').val();
    if (nickname=='' || nickname=='undefined') {
        getErrMsg('昵称没有填写！',''); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate,
        nickname:nickname
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/nick-set',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            $('#nickname').html(nickname);
            $('#pop').hide();
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 性别选择
 * */
function getSexName(){
    var h = '';
    h += '<div onclick="setSexName(1)">男</div>';
    h += '<div onclick="setSexName(2)">女</div>';
    h += '<div id="popClose" onclick="popClose()">取消</div>';
    $('#popDetail').html(h);
    $('#pop').show();
}

/**
 * 性别设置
 * */
function setSexName(v){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        window.location.href = '/h5/login/login.html';
    }
    if (v==0) {
        getErrMsg('性别没有选择！',''); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate,
        sex:v
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/sex-set',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            var sexName;
            if (v==1) {
                sexName = '男';
            } else {
                sexName = '女';
            }
            $('#sexName').html(sexName);
            $('#pop').hide();
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 弹窗隐藏
 * */
function popClose(){
    $('#popDetail').html('');
    $('#pop').hide();
}

/**
 * 密码更新
 * */
function setPwd(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var pwd = $('#pwd').val();
    var pwd1 = $('#pwd1').val();
    var pwd2 = $('#pwd2').val();
    if (pwd=='' || pwd=='undefined') {
        getErrMsg('原密码没有填写！',''); return;
    }
    if (pwd2=='' || pwd2=='undefined') {
        getErrMsg('新密码没有填写！',''); return;
    }
    if (pwd2!=pwd1) {
        getErrMsg('两次密码填写不相同！',''); return;
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate,
        pwd:pwd,
        pwd2:pwd2
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/pwd-set',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            setTimeout(function(){
                cacheDel('userInfo');
                getAppErrMsg('更新成功！','/h5/login/login.html',0);
                return;
            },1000);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * --------------------
 * 我的信息
 * --------------------
 * */





/**
 * --------------------
 * 员工信息
 * --------------------
 * */

/**
 * 员工基本信息
 * */
function getStaffBasicInfo() {
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/staff/basic-get',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            //console.log(res.data); return;
            var data = res.data;
            $('#realname').html(data.realname);
            $('#birthName').html(data.birthName);
            $('#eduName').html(data.eduName);
            $('#weight').html(data.weight);
            $('#polityName').html(data.polityName);
            $('#nativePlace').html(data.nativePlace);
            $('#nation').html(data.nation);
            $('#marryName').html(data.marryName);
            $('#idcard').html(data.idcard);
            $('#house').html(data.house);
            $('#image').html("<img src='"+data.image+"'/>");
            $('#houseAddress').html(data.houseAddress);
            $('#liveAddress').html(data.liveAddress);
            $('#contactPerson').html(data.contactPerson);
            $('#contactPhone').html(data.contactPhone);
            $('#salary').html(data.salary);
            var i, i2, h = '', h2 = '';
            for (i=0;i<data.skillNames.length;i++) {
                if (i>0) { h += '，'; }
                h += data.skillNames[i].name;
            }
            $('#skillNames').html(h);
            for (i2=0;i2<data.hobbyNames.length;i2++) {
                if (i2>0) { h2 += '，'; }
                h2 += data.hobbyNames[i2].name;
            }
            $('#hobbyNames').html(h2);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 员工扩展信息
 * */
function getStaffExtInfo(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/staff/ext-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            var h = '';
            if (res.code != 0) {
                h += '<p>没有资料</p>';
                $('#orderParamList').html(h);
                console.log(res); return;
            }
            //console.log(res.data)
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 员工认证信息
 * */
function getStaffFile(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/staff/ext-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            var h = '';
            if (res.code != 0) {
                h += '<p>没有图片</p>';
                $('#orderParamList').html(h);
                console.log(res); return;
            }
            //console.log(res.data)
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * --------------------
 * 员工信息
 * --------------------
 * */





/**
 * --------------------
 * 公司信息
 * --------------------
 * */

/**
 * 基本信息
 * */
function getBasicInfo() {
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/company/basic-get',
        data:data,
        success:function(res){
            //console.log(res); return;
            if (res.code!=0) {
                console.log(res); return;
            }
            console.log(res.data);
            // return;
            var legalSexName, data = res.data;
            $('#legalName').html(data.legalName);
            if (data.legalSex==1) {
                legalSexName = '男';
            } else {
                legalSexName = '女';
            }
            $('#legalSexName').html(legalSexName);
            $('#legalMobile').html(data.legalMobile);
            $('#legalIdcard').html(data.legalIdcard);
            var i, h = '';
            for (i=0;i<data.images.length;i++) {
                h += '<img src="'+data.images[i]+'" height="20"/>';
            }
            $('#images').html(h);
            $('#comName').html(data.comName);
            $('#comTel').html(data.comTel);
            $('#comFax').html(data.comFax);
            $('#comAddress').html(data.comAddress);
            $('#comCity').html(data.comCity);
            $('#cusLike').html(data.cusLike);
            $('#quality').html(data.quality);
            $('#pact').html(data.pact);
            $('#outType').html(data.outType);
            $('#ageRange').html(data.ageRange);
            $('#detail').html(data.detail);
            $('#facTypeName').html(data.facTypeName);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 认证
 * */
function getFile(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/company/file-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            if (res.code != 0) {
                console.log(res); return;
            }
            //console.log(res.data); return;
            var legals = res.data.legals;
            var coms = res.data.coms;
            if (legals.length > 0) {
                var i, i2, i3, i4, i5, i6,
                    h, h2, h3, h4, h5, h6;
                var photos = legals.photos;
                var idcards = legals.idcards;
                var graduates = legals.graduates;
                var honors = legals.honors;
                var marrys = legals.marrys;
                var drives = legals.drives;
                h = '<input type="hidden" id="photoCount" value="'+photos.length+'"/>';
                h2 = '<input type="hidden" id="idcardCount" value="'+idcards.length+'"/>';
                h3 = '<input type="hidden" id="graduateCount" value="'+graduates.length+'"/>';
                h4 = '<input type="hidden" id="honorCount" value="'+honors.length+'"/>';
                h5 = '<input type="hidden" id="marrCount" value="'+marrs.length+'"/>';
                h6 = '<input type="hidden" id="driveCount" value="'+drives.length+'"/>';
                for (i=0;i<photos.length;i++) {
                    h += '<input type="hidden" id="photo-'+i+'" value="'+photos[i]+'"/>';
                }
                for (i2=0;i2<idcards.length;i2++) {
                    h2 += '<input type="hidden" id="idcard-'+i2+'" value="'+idcards[i2]+'"/>';
                }
                for (i3=0;i3<graduates.length;i3++) {
                    h3 += '<input type="hidden" id="graduate-'+i3+'" value="'+graduates[i3]+'"/>';
                }
                for (i4=0;i4<honors.length;i4++) {
                    h4 += '<input type="hidden" id="honor-'+i4+'" value="'+honors[i4]+'"/>';
                }
                for (i5=0;i5<marrys.length;i5++) {
                    h5 += '<input type="hidden" id="marry-'+i5+'" value="'+marrys[i5]+'"/>';
                }
                for (i6=0;i6<drives.length;i6++) {
                    h6 += '<input type="hidden" id="drive-'+i6+'" value="'+drives[i6]+'"/>';
                }
                $('#photos').html('有'+legals.photos.length+'张，点击查看'+h);
                $('#idcards').html('有'+legals.idcards.length+'张，点击查看'+h2);
                $('#graduates').html('有'+legals.graduates.length+'张，点击查看'+h3);
                $('#honors').html('有'+legals.honors.length+'张，点击查看'+h4);
                $('#marrys').html('有'+legals.marrys.length+'张，点击查看'+h5);
                $('#drives').html('有'+legals.drives.length+'张，点击查看'+h6);
            }
            if (coms.length > 0) {
                var i11, i12, i13, i14, i15, i16,
                    h11, h12, h13, h14, h15, h16;
                var zzjgdms = coms.zzjgdms;
                var yyzzs = coms.yyzzs;
                var swdjs = coms.swdjs;
                var honor2s = coms.honors;
                var houses = coms.houses;
                h11 = '<input type="hidden" id="zzjgdmCount" value="'+zzjgdms.length+'"/>';
                h12 = '<input type="hidden" id="yyzzCount" value="'+yyzzs.length+'"/>';
                h13 = '<input type="hidden" id="swdjCount" value="'+swdjs.length+'"/>';
                h14 = '<input type="hidden" id="honor2Count" value="'+honor2s.length+'"/>';
                h15 = '<input type="hidden" id="houseCount" value="'+houses.length+'"/>';
                for (i11=0;i11<zzjgdms.length;i11++) {
                    h11 += '<input type="hidden" id="zzjgdm-'+i11+'" value="'+zzjgdms[i11]+'"/>';
                }
                for (i12=0;i12<yyzzs.length;i12++) {
                    h12 += '<input type="hidden" id="yyzz-'+i12+'" value="'+yyzzs[i12]+'"/>';
                }
                for (i13=0;i13<swdjs.length;i13++) {
                    h13 += '<input type="hidden" id="swdj-'+i13+'" value="'+swdjs[i13]+'"/>';
                }
                for (i14=0;i14<honor2s.length;i14++) {
                    h14 += '<input type="hidden" id="honor2-'+i14+'" value="'+honor2s[i14]+'"/>';
                }
                for (i15=0;i15<houses.length;i15++) {
                    h15 += '<input type="hidden" id="house-'+i15+'" value="'+houses[i15]+'"/>';
                }
                $('#zzjgdms').html('有'+coms.zzjgdms.length+'张，点击查看'+h11);
                $('#yyzzs').html('有'+coms.yyzzs.length+'张，点击查看'+h12);
                $('#swdjs').html('有'+coms.swdjs.length+'张，点击查看'+h13);
                $('#honor2s').html('有'+coms.honors.length+'张，点击查看'+h14);
                $('#houses').html('有'+coms.houses.length+'张，点击查看'+h15);
            }
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 图片查看
 * */
function showFile(fileName){
    var count = $('#'+fileName+'Count').val();
    var file, h = '';
    //console.log(fileName,count);
    if (count==0 || count==null) {
        getErrMsg('没有图片！',''); return;
    }
    for (var i=0;i<count;i++) {
        file = $('#'+fileName+'-'+i).val();
        h += '<img src="'+file+'" width="100%"/>';
    }
    $('#popFile').html(h);
    $('#pop').show();
}

/**
 * 产品
 * */
function getPro(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/company/product-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            if (res.code != 0) {
                console.log(res); return;
            }
            //console.log(res.data); return;
            var h = '', h1 = '',h2 = '', h3 = '';
            var zhen = res.data.zhen;
            var suo = res.data.suo;
            var bao = res.data.bao;
            h += '<tr>';
            h += '<td class="left">产品名称</td>';
            h += '<td colspan="2">没有产品</td>';
            h += '</tr>';
            if (zhen.length == 0) {
                $('#zhen').html(h);
            }
            if (suo.length == 0) {
                $('#suo').html(h);
            }
            if (bao.length == 0) {
                $('#bao').html(h);
            }
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 设备
 * */
function getEquip(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/company/equip-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            var i, h = '';
            h += '<tr>';
            h += '<td style="width:20%">设备</td>';
            h += '<td style="width:20%">品牌</td>';
            h += '<td style="width:20%">年限</td>';
            h += '<td style="width:20%">数量</td>';
            h += '<tr>';
            if (res.code != 0) {
                h += '<tr>';
                h += '<td colspan="4">没有资料</td>';
                h += '<tr>';
                $('#equip').html(h);
                console.log(res); return;
            }
            //console.log(res.data); return;
            for (i=0;i<res.data.length;i++) {
                h += '<tr>';
                h += '<td>'+res.data[i].name+'</td>';
                h += '<td>'+res.data[i].brand+'</td>';
                h += '<td>'+res.data[i].year+'</td>';
                h += '<td>'+res.data[i].num+'</td>';
                h += '<tr>';
            }
            $('#equip').html(h);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 产量产能
 * */
function getYield(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/company/yield-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            var h = '';
            if (res.code != 0) {
                h += '<tr>';
                h += '<td colspan="4">没有资料</td>';
                h += '</tr>';
                $('#depart').html(h);
                $('#dayOutPut').html(h);
                $('#requirePro').html(h);
                $('#requireDepart').html(h);
                $('#standard').html(h);
                console.log(res); return;
            }
            //console.log(res.data); return;
            var depart = res.data.departs;
            var dayOutPut = res.data.dayOutPuts;
            var requirePro = res.data.requirePros;
            var requireDepart = res.data.requireDeparts;
            var standard = res.data.standards;
            var i, i2, i3, i4, i5,
                h1 = '', h2 = '', h3 = '', h4 = '', h5 = '';
            h2 += '<tr>';
            h2 += '<td class="left">核心部门</td>';
            h2 += '<td>人数</td>';
            h2 += '</tr>';
            if (depart.length > 0) {
                for (i=0;i<depart.length;i++) {
                    h1 = '<tr>';
                    h1 += '<td class="left">'+depart[i].key+'</td>';
                    h1 += '<td>'+depart[i].num+'</td>';
                    h1 += '</tr>';
                }
            } else {
                h1 += '<tr>';
                h1 += '<td colspan="2">没有资料</td>';
                h1 += '</tr>';
            }
            $('#depart').html(h1);
            if (dayOutPut.length > 0) {
                h2 += '<tr>';
                h2 += '<td class="left">'+dayOutPut[0]+'</td>';
                h2 += '<td>'+dayOutPut[1]+'</td>';
                h2 += '</tr>';
            }
            $('#dayOutPut').html(h2);
            if (requirePro.length > 0) {
                for (i3=0;i3<requirePro.length;i3++) {
                    h3 += '<tr>';
                    h3 += '<td class="left">'+requirePro[i3].key+'</td>';
                    h3 += '<td>'+requirePro[i3].val+'</td>';
                    h3 += '</tr>';
                }
            } else {
                h3 += '<tr>';
                h3 += '<td colspan="2">没有资料</td>';
                h3 += '</tr>';
            }
            $('#requirePro').html(h3);
            if (requireDepart.length > 0) {
                for (i4=0;i4<requireDepart.length;i4++) {
                    h4 += '<tr>';
                    h4 += '<td class="left">'+requireDepart[i4].key+'</td>';
                    h4 += '<td>'+requireDepart[i4].num+'</td>';
                    h4 += '</tr>';
                }
            } else {
                h4 += '<tr>';
                h4 += '<td colspan="4">没有资料</td>';
                h4 += '</tr>';
            }
            $('#requireDepart').html(h4);
            var standards = [
                '《工艺单》、样品',
                '摊平用尺量用目视用手摸',
                '质检：每件产品全检',
                '总检：抽查品质、尺寸',
                '巡检：对在线生产产品巡查'
            ];
            for (i5=0;i5<standard.length;i5++) {
                if (standard[i5]!=0) {
                    h5 += '<tr>';
                    h5 += '<td colspan="2">'+standards[i5]+'</td>';
                    h5 += '</tr>';
                }
                //else {
                //    h5 += '<tr>';
                //    h5 += '<td colspan="2">没有资料</td>';
                //    h5 += '</tr>';
                //}
            }
            $('#standard').html(h5);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 环境
 * */
function getEnv(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    //var envFac = [
    //    'managers','facManagers','finances','guards','shapes','raws',
    //    'techs','works','backs','cuts','dorms','samples'
    //];
    //var envCom = [
    //    'managers','manager2s','directors','handles','finances','officers',
    //    'sales','expands','designs','buyers','sellers','produces',
    //    'qcs','storages','transports','outs','meetings','halls',
    //    'stages','talks','cooks','wcs','teas','dorms'
    //];
    var envFac = [
        [
            'manager','facManager','finance','guard','shape','raw',
            'tech','work','back','cut','dorm','sample'
         ],
        [

            '总经理','厂长','财务室','门卫','厂房外形图','充绒房',
            '技术部','缝制车间','后道车间','裁剪车间','工厂宿舍','样衣间'
        ]
    ];
    var envCom = [
        [
            'manager','manager2','director','handle','finance','officer',
            'sale','expand','design','buyer','seller','produce',
            'qc','storage','transport','out','meeting','hall',
            'stage','talk','cook','wc','tea','dorm'
        ],
        [
            '总经理','副总经理','总监','总经办','财务室','行政部',
            '销售部','拓展部','设计部','采购部','电商部','生产部',
            '品控部','仓储部','物流部','外发部','会议室','展厅',
            '仓储部','谈判室','厨房','厕所','茶水间','宿舍'
        ]
    ];
    var i, h = '';
    if (userInfo.type==3) {
        for (i=0;i<envFac[0].length;i++) {
            h += '<tr>';
            h += '<td class="left">'+envFac[1][i]+'</td>';
            h += '<td id="'+envFac[0][i]+'" onclick="showFile(\''+envFac[0][i]+'\')">有0张，点击查看</td>';
            h += '</tr>';
        }
    } else {
        for (i=0;i<envCom[0].length;i++) {
            h += '<tr>';
            h += '<td class="left">'+envCom[1][i]+'</td>';
            h += '<td id="'+envCom[0][i]+'" onclick="showFile(\''+envCom[0][i]+'\')">有0张，点击查看</td>';
            h += '</tr>';
        }
    }
    $('#env').html(h);
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/company/env-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            //var h = '';
            //h += '<tr>';
            //h += '<td colspan="2">没有图片</td>';
            //h += '</tr>';
            //$('#env').html(h);
            if (res.code != 0) {
                console.log(res); return;
            }
            //console.log(res.data); return;
            var data = res.data;
            var i, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12,
                i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23, i24,
                h = '', h2 = '', h3 = '', h4 = '', h5 = '', h6 = '',
                h7 = '', h8 = '', h9 = '', h10 = '', h11 = '', h12 = '',
                h13 = '', h14 = '', h15 = '', h16 = '', h17 = '', h18 = '',
                h19 = '', h20 = '', h21 = '', h22 = '', h23 = '', h24 = '';
            if (userInfo.type==3) {
                h = '<input type="hidden" id="managerCount" value="'+data.managers.length+'"/>';
                h2 = '<input type="hidden" id="facManagerCount" value="'+data.facManagers.length+'"/>';
                h3 = '<input type="hidden" id="financeCount" value="'+data.finances.length+'"/>';
                h4 = '<input type="hidden" id="guardCount" value="'+data.guards
.length+'"/>';
                h5 = '<input type="hidden" id="shapeCount" value="'+data.shapes.length+'"/>';
                h6 = '<input type="hidden" id="rawCount" value="'+data.raws.length+'"/>';
                h7 = '<input type="hidden" id="techCount" value="'+data.techs.length+'"/>';
                h8 = '<input type="hidden" id="workCount" value="'+data.works.length+'"/>';
                h9 = '<input type="hidden" id="backCount" value="'+data.backs.length+'"/>';
                h10 = '<input type="hidden" id="cutCount" value="'+data.cuts.length+'"/>';
                h11 = '<input type="hidden" id="dormCount" value="'+data.dorms.length+'"/>';
                h12 = '<input type="hidden" id="sampleCount" value="'+data.samples.length+'"/>';
                for (i=0;i<data.managers.length;i++) {
                    h += '<input type="hidden" id="manager-'+i+'" value="'+data.managers[i]+'"/>';
                }
                for (i2=0;i2<data.facManagers.length;i2++) {
                    h2 += '<input type="hidden" id="facManager-'+i2+'" value="'+data.facManagers[i2]+'"/>';
                }
                for (i3=0;i3<data.finances.length;i3++) {
                    h3 += '<input type="hidden" id="finance-'+i3+'" value="'+data.finances[i3]+'"/>';
                }
                for (i4=0;i4<data.guards.length;i4++) {
                    h4 += '<input type="hidden" id="guard-'+i5+'" value="'+data.guards[i5]+'"/>';
                }
                for (i5=0;i5<data.shapes.length;i5++) {
                    h5 += '<input type="hidden" id="shape-'+i5+'" value="'+data.shapes[i5]+'"/>';
                }
                for (i6=0;i6<data.raws.length;i6++) {
                    h6 += '<input type="hidden" id="raw-'+i6+'" value="'+data.raws[i6]+'"/>';
                }
                for (i7=0;i7<data.techs.length;i7++) {
                    h7 += '<input type="hidden" id="tech-'+i7+'" value="'+data.techs[i7]+'"/>';
                }
                for (i8=0;i8<data.works.length;i8++) {
                    h8 += '<input type="hidden" id="work-'+i8+'" value="'+data.works[i8]+'"/>';
                }
                for (i9=0;i9<data.backs.length;i9++) {
                    h9 += '<input type="hidden" id="back-'+i9+'" value="'+data.backs[i9]+'"/>';
                }
                for (i10=0;i10<data.cuts.length;i10++) {
                    h10 += '<input type="hidden" id="cut-'+i10+'" value="'+data.cuts[i10]+'"/>';
                }
                for (i11=0;i11<data.dorms.length;i11++) {
                    h11 += '<input type="hidden" id="dorm-'+i11+'" value="'+data.dorms[i11]+'"/>';
                }
                for (i12=0;i12<data.samples.length;i12++) {
                    h12 += '<input type="hidden" id="sample-'+i12+'" value="'+data.samples[i12]+'"/>';
                }
                //'manager','facManager','finance','guard','shape','raw',
                //'tech','work','back','cut','dorm','sample'
                $('#manager').html('有'+data.managers.length+'张，点击查看'+h);
                $('#facManager').html('有'+data.facManagers.length+'张，点击查看'+h2);
                $('#finance').html('有'+data.finances.length+'张，点击查看'+h3);
                $('#guard').html('有'+data.guards.length+'张，点击查看'+h4);
                $('#shape').html('有'+data.shapes.length+'张，点击查看'+h5);
                $('#raw').html('有'+data.raws.length+'张，点击查看'+h6);
                $('#tech').html('有'+data.techs.length+'张，点击查看'+h7);
                $('#work').html('有'+data.works.length+'张，点击查看'+h8);
                $('#back').html('有'+data.backs.length+'张，点击查看'+h9);
                $('#cut').html('有'+data.cuts.length+'张，点击查看'+h10);
                $('#dorm').html('有'+data.dorms.length+'张，点击查看'+h11);
                $('#sample').html('有'+data.samples.length+'张，点击查看'+h12);
            } else {
                //'manager','manager2','director','handle','finance','officer',
                //'sale','expand','design','buyer','seller','produce',
                //'qc','storage','transport','out','meeting','hall',
                //'stage','talk','cook','wc','tea','dorm'
                h = '<input type="hidden" id="managerCount" value="'+data.managers.length+'"/>';
                h2 = '<input type="hidden" id="manager2Count" value="'+data.manager2s.length+'"/>';
                h3 = '<input type="hidden" id="directorCount" value="'+data.directors.length+'"/>';
                h4 = '<input type="hidden" id="handleCount" value="'+data.handles.length+'"/>';
                h5 = '<input type="hidden" id="financeCount" value="'+data.finances
.length+'"/>';
                h6 = '<input type="hidden" id="officerCount" value="'+data.officers
.length+'"/>';
                h7 = '<input type="hidden" id="saleCount" value="'+data.sales
.length+'"/>';
                h8 = '<input type="hidden" id="expandCount" value="'+data.expands.length+'"/>';
                h9 = '<input type="hidden" id="designCount" value="'+data.designs.length+'"/>';
                h10 = '<input type="hidden" id="buyerCount" value="'+data.buyers.length+'"/>';
                h11 = '<input type="hidden" id="sellerCount" value="'+data.sellers.length+'"/>';
                h12 = '<input type="hidden" id="produceCount" value="'+data.produces.length+'"/>';
                h13 = '<input type="hidden" id="qcCount" value="'+data.qcs.length+'"/>';
                h14 = '<input type="hidden" id="storageCount" value="'+data.storages.length+'"/>';
                h15 = '<input type="hidden" id="transportCount" value="'+data.transports.length+'"/>';
                h16 = '<input type="hidden" id="outCount" value="'+data.outs.length+'"/>';
                h17 = '<input type="hidden" id="meetingCount" value="'+data.meetings.length+'"/>';
                h18 = '<input type="hidden" id="hallCount" value="'+data.halls.length+'"/>';
                h19 = '<input type="hidden" id="stageCount" value="'+data.stages.length+'"/>';
                h20 = '<input type="hidden" id="talkCount" value="'+data.talks.length+'"/>';
                h21 = '<input type="hidden" id="cookCount" value="'+data.cooks.length+'"/>';
                h22 = '<input type="hidden" id="wcCount" value="'+data.wcs.length+'"/>';
                h23 = '<input type="hidden" id="teaCount" value="'+data.teas.length+'"/>';
                h24 = '<input type="hidden" id="dormCount" value="'+data.dorms
.length+'"/>';
                for (i=0;i<data.managers.length;i++) {
                    h += '<input type="hidden" id="manager-'+i+'" value="'+data.managers[i]+'"/>';
                }
                for (i2=0;i2<data.manager2s.length;i2++) {
                    h2 += '<input type="hidden" id="manager2-'+i2+'" value="'+data.manager2s[i2]+'"/>';
                }
                for (i3=0;i3<data.directors.length;i3++) {
                    h3 += '<input type="hidden" id="director-'+i3+'" value="'+data.directors[i3]+'"/>';
                }
                for (i4=0;i4<data.handles.length;i4++) {
                    h4 += '<input type="hidden" id="handle-'+i4+'" value="'+data.handles[i4]+'"/>';
                }
                for (i5=0;i5<data.finances.length;i5++) {
                    h5 += '<input type="hidden" id="finance-'+i5+'" value="'+data.finances[i5]+'"/>';
                }
                for (i6=0;i6<data.officers.length;i6++) {
                    h6 += '<input type="hidden" id="officer-'+i6+'" value="'+data.officers[i6]+'"/>';
                }
                for (i7=0;i7<data.sales.length;i7++) {
                    h7 += '<input type="hidden" id="sale-'+i7+'" value="'+data.sales[i7]+'"/>';
                }
                for (i8=0;i8<data.expands.length;i8++) {
                    h8 += '<input type="hidden" id="expand-'+i8+'" value="'+data.expands[i8]+'"/>';
                }
                for (i9=0;i9<data.designs.length;i9++) {
                    h9 += '<input type="hidden" id="design-'+i9+'" value="'+data.designs[i9]+'"/>';
                }
                for (i10=0;i10<data.buyers.length;i10++) {
                    h10 += '<input type="hidden" id="buyer-'+i10+'" value="'+data.buyers[i10]+'"/>';
                }
                for (i11=0;i11<data.sellers.length;i11++) {
                    h11 += '<input type="hidden" id="seller-'+i11+'" value="'+data.sellers[i11]+'"/>';
                }
                for (i12=0;i12<data.produces.length;i12++) {
                    h12 += '<input type="hidden" id="produce-'+i12+'" value="'+data.produces[i12]+'"/>';
                }
                for (i13=0;i13<data.qcs.length;i13++) {
                    h13 += '<input type="hidden" id="qc-'+i13+'" value="'+data.qcs[i13]+'"/>';
                }
                for (i14=0;i14<data.storages.length;i14++) {
                    h14 += '<input type="hidden" id="storage-'+i14+'" value="'+data.storages[i14]+'"/>';
                }
                for (i15=0;i15<data.transports.length;i15++) {
                    h15 += '<input type="hidden" id="transport-'+i15+'" value="'+data.transports[i15]+'"/>';
                }
                for (i16=0;i16<data.outs.length;i16++) {
                    h16 += '<input type="hidden" id="out-'+i16+'" value="'+data.outs[i16]+'"/>';
                }
                for (i17=0;i17<data.meetings.length;i17++) {
                    h17 += '<input type="hidden" id="meeting-'+i17+'" value="'+data.meetings[i17]+'"/>';
                }
                for (i18=0;i18<data.halls.length;i18++) {
                    h18 += '<input type="hidden" id="hall-'+i18+'" value="'+data.halls[i18]+'"/>';
                }
                for (i19=0;i19<data.stages.length;i19++) {
                    h19 += '<input type="hidden" id="stage-'+i19+'" value="'+data.stages[i19]+'"/>';
                }
                for (i20=0;i20<data.talks.length;i20++) {
                    h20 += '<input type="hidden" id="talk-'+i20+'" value="'+data.talks[i20]+'"/>';
                }
                for (i21=0;i21<data.cooks.length;i21++) {
                    h21 += '<input type="hidden" id="cook-'+i21+'" value="'+data.cooks[i21]+'"/>';
                }
                for (i22=0;i22<data.wcs.length;i22++) {
                    h22 += '<input type="hidden" id="wc-'+i22+'" value="'+data.wcs[i22]+'"/>';
                }
                for (i23=0;i23<data.teas.length;i23++) {
                    h23 += '<input type="hidden" id="tea-'+i23+'" value="'+data.teas[i23]+'"/>';
                }
                for (i24=0;i24<data.dorms.length;i24++) {
                    h24 += '<input type="hidden" id="dorm-'+i24+'" value="'+data.dorms[i24]+'"/>';
                }
                $('#manager').html('有'+data.managers.length+'张，点击查看'+h);
                $('#manager2').html('有'+data.manager2s.length+'张，点击查看'+h2);
                $('#director').html('有'+data.directors.length+'张，点击查看'+h3);
                $('#handle').html('有'+data.handles.length+'张，点击查看'+h4);
                $('#finance').html('有'+data.finances.length+'张，点击查看'+h5);
                $('#officer').html('有'+data.officers.length+'张，点击查看'+h6);
                $('#sale').html('有'+data.sales.length+'张，点击查看'+h7);
                $('#expand').html('有'+data.expands.length+'张，点击查看'+h8);
                $('#design').html('有'+data.designs.length+'张，点击查看'+h9);
                $('#buyer').html('有'+data.buyers.length+'张，点击查看'+h10);
                $('#seller').html('有'+data.sellers.length+'张，点击查看'+h11);
                $('#produce').html('有'+data.produces.length+'张，点击查看'+h12);
                $('#qc').html('有'+data.qcs.length+'张，点击查看'+h13);
                $('#storage').html('有'+data.storages.length+'张，点击查看'+h14);
                $('#transport').html('有'+data.transports.length+'张，点击查看'+h15);
                $('#out').html('有'+data.outs.length+'张，点击查看'+h16);
                $('#meeting').html('有'+data.meetings.length+'张，点击查看'+h17);
                $('#hall').html('有'+data.halls.length+'张，点击查看'+h18);
                $('#stage').html('有'+data.stages.length+'张，点击查看'+h19);
                $('#talk').html('有'+data.talks.length+'张，点击查看'+h20);
                $('#cook').html('有'+data.cooks.length+'张，点击查看'+h21);
                $('#wc').html('有'+data.wcs.length+'张，点击查看'+h22);
                $('#tea').html('有'+data.teas.length+'张，点击查看'+h23);
                $('#dorm').html('有'+data.dorms.length+'张，点击查看'+h24);
            }
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 产品风格
 * */
function getStyle(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/company/style-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            var h = '';
            if (res.code != 0) {
                h += '<tr>';
                h += '<td class="left">风格名称</td>';
                h += '<td>没有风格</td>';
                h += '<tr>';
                $('#style').html(h);
                console.log(res); return;
            }
            //console.log(res.data); return;
            for (var i=0;i<res.data.length;i++) {
                h += '<tr>';
                h += '<td class="left">风格名称</td>';
                h += '<td>'+res.data[i].name+'</td>';
                h += '<tr>';
            }
            $('#style').html(h);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * 款式数量
 * */
function getDesign(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo == 'undefined' || userInfo.token == 'undefined') {
        window.location.href = '/h5/login/login.html';
    }
    var data = {
        app_access:app_access,
        token:userInfo.token,
        type:userInfo.type,
        cate:userInfo.cate
    };
    $.ajax({
        type:'post',
        url:getDomain() + 'myset/company/design-get',
        data:data,
        success:function(res) {
            //console.log(res); return;
            var h = '';
            h += '<tr>';
            h += '<td class="left">款式名称</td>';
            h += '<td>数量</td>';
            h += '<tr>';
            if (res.code != 0) {
                h += '<tr>';
                h += '<td class="left">没有款式</td>';
                h += '<td>没有数量</td>';
                h += '<tr>';
                $('#design').html(h);
                console.log(res); return;
            }
            //console.log(res.data); return;
            for (var i=0;i<res.data.length;i++) {
                h += '<tr>';
                h += '<td class="left">'+res.data[i].name+'</td>';
                h += '<td>'+res.data[i].num+'</td>';
                h += '<tr>';
            }
            $('#design').html(h);
        },
        error:function(){
            console.log('操作失败！'); return;
        }
    });
}

/**
 * --------------------
 * 公司信息
 * --------------------
 * */





/**
 * --------------------
 * 我的设置
 * --------------------
 * */

/**
 * 退出提醒
 * */
function getlogoutPop(){
    var h = '';
    h += '<div id="popClose" onclick="setLogout()">确定退出</div>';
    h += '<div onclick="popClose()">取消</div>';
    $('#popDetail').html(h);
    $('#pop').show();
}

/**
 * 退出登录
 * */
function setLogout(){
    var userInfo = cacheGet('userInfo'); //获取用户信息
    if (userInfo==null || userInfo.token=='undefined') {
        window.location.href = '/h5/login/login.html';
    }
    cacheDel('userInfo'); //清除缓存
    getErrMsg('退出成功！','/h5/login/login.html');
    //window.location.href = '/h5/login/login.html';
    //return;
    //var data = {
    //    app_access:app_access,
    //    token:userInfo.token,
    //    type:userInfo.type,
    //    cate:userInfo.cate
    //};
    //$.ajax({
    //    type: 'post',
    //    url: getDomain() + 'myset/logout',
    //    data: data,
    //    success: function (res) {
    //        //console.log(res); return;
    //        if (res.code != 0) {
    //            console.log(res);
    //            return;
    //        }
    //    },
    //    error: function () {
    //        console.log('操作失败！');
    //        return;
    //    }
    //});
}

/**
 * --------------------
 * 我的设置
 * --------------------
 * */





/**
 * --------------------
 * 我的账户
 * --------------------
 * */

/**
 * --------------------
 * 我的账户
 * --------------------
 * */





/**
 * --------------------
 * 我的工作
 * --------------------
 * */

/**
 * --------------------
 * 我的工作
 * --------------------
 * */





/**
 * 地址前缀
 * */
function getDomain(){
    return '/api/my/';
}


///**
// * -------------------------
// * 本地缓存
// * -------------------------
// * */
//
///**
// * 本地缓存，获取
// * */
//function cacheGet(key){
//    //return localStorage.getItem(key);
//    return JSON.parse(localStorage.getItem(key));
//}
//
///**
// * 本地缓存，新增
// * */
//function cacheSet(key,val){
//    //var cache = cacheGet(key);
//    //if (cache!='undefined') { getErrMsg('已存在！',''); }
//    //localStorage.setItem(key,val);
//    //为防止没有设置值获取后出现object类型 转化出错,提前进行设置空字符串
//    localStorage.setItem(key, "");
//    localStorage.setItem(key, JSON.stringify(val));
//}
//
///**
// * 本地缓存，删除
// * */
//function cacheDel(key){
//    localStorage.removeItem(key);
//}
//
///**
// * 本地缓存，删除
// * */
//function cacheClear(){
//    localStorage.clear();
//}





/**
 * 错误提示框
 * */
function getErrMsg(msg,url){
    var h = '';
    h += '<span>'+msg+'</span>';
    h += '<script>';
    h += 'setTimeout("setErrClose()",1000*3); function setErrClose(){ $("#errMsg").html("").hide(); }';
    if (url!='') {
        h += 'setTimeout("setJump()",1000*3); function setJump(){ window.location.href=\''+url+'\'; }';
    }
    h += '</script>';
    $('#errMsg').html(h).show();
}